package com.huike.clues.service.impl;


import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {

    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;


    /**
     * 新增线索跟进记录
     *
     * @param clueTrackRecordVo
     * @return
     */
    @Override
    public AjaxResult add(ClueTrackRecordVo clueTrackRecordVo) {
        String currentUsername = SecurityContextHolder.getContext().getAuthentication().getName();

        int result = tbClueTrackRecordMapper.insertTrackRecord(clueTrackRecordVo, currentUsername);
        if (result > 0) {
            return AjaxResult.success("操作成功");
        } else {
            return AjaxResult.error("操作失败");
        }
    }

    @Override
    public List<ClueTrackRecordVo> selectClueTrackRecordList(ClueTrackRecordVo clueTrackRecordVo) {
        return tbClueTrackRecordMapper.selectClueTrackRecordList(clueTrackRecordVo);
    }
}
